package cc.mrbird.febs.order.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import cc.mrbird.febs.common.entity.QueryRequest;
import cc.mrbird.febs.order.entity.OrderPay;
import cc.mrbird.febs.order.mapper.OrderPayMapper;
import cc.mrbird.febs.order.service.IOrderPayService;
import lombok.RequiredArgsConstructor;

/**
 * 订单支付表 Service实现
 *
 * @author Lord
 * @date 2020-06-06 17:07:09
 */
@Service
@RequiredArgsConstructor
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class OrderPayServiceImpl extends ServiceImpl<OrderPayMapper, OrderPay> implements IOrderPayService {

    @Override
    public IPage<OrderPay> findOrderPays(QueryRequest request, OrderPay orderPay) {
        LambdaQueryWrapper<OrderPay> queryWrapper = new LambdaQueryWrapper<>();
        // TODO 设置查询条件
        Page<OrderPay> page = new Page<>(request.getPageNum(), request.getPageSize());
        return this.page(page, queryWrapper);
    }

    @Override
    public List<OrderPay> findOrderPays(OrderPay orderPay) {
        LambdaQueryWrapper<OrderPay> queryWrapper = new LambdaQueryWrapper<>();
        // TODO 设置查询条件
        return this.baseMapper.selectList(queryWrapper);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void createOrderPay(OrderPay orderPay) {
        this.save(orderPay);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void updateOrderPay(OrderPay orderPay) {
        this.saveOrUpdate(orderPay);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteOrderPay(OrderPay orderPay) {
        LambdaQueryWrapper<OrderPay> wrapper = new LambdaQueryWrapper<>();
        // TODO 设置删除条件
        this.remove(wrapper);
    }
}
